<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Prototype Unit test file</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="../../dist/prototype.js" type="text/javascript"></script>
  <script src="../lib/unittest.js" type="text/javascript"></script>
  <link rel="stylesheet" href="../test.css" type="text/css" />
  <style type="text/css" media="screen">
  /* <![CDATA[ */
    #testcss1 { font-size:11px; color: #f00; }
    #testcss2 { font-size:12px; color: #0f0; display: none; }
  /* ]]> */
  </style>
</head>
<body>
<h1>Prototype Unit test file</h1>
<p>
  Test of the Hash.prototype extensions
</p>

<!-- Log output -->
<div id="testlog"> </div>

<!-- Tests follow -->
<script type="text/javascript" language="javascript" charset="utf-8">
// <![CDATA[

  var Fixtures = {
    one: {
      a: 'A#'
    },
    
    many: {
      a: 'A',
      b: 'B',
      c: 'C',
      d: 'D#'
    },
    
    value_undefined: { a:"b", c:undefined },
    value_null: { a:"b", c:null },
    value_zero: { a:"b", c:0 }
  };
  
  new Test.Unit.Runner({
    
    testKeys: function(){ with(this) {
      assertEnumEqual([],                   $H({}).keys())
      assertEnumEqual(['a'],                $H(Fixtures.one).keys())
      assertEnumEqual(['a', 'b', 'c', 'd'], $H(Fixtures.many).keys())
    }},
    
    testValues: function(){ with(this) {
      assertEnumEqual([],                    $H({}).values())
      assertEnumEqual(['A#'],                $H(Fixtures.one).values())
      assertEnumEqual(['A', 'B', 'C', 'D#'], $H(Fixtures.many).values())
    }},  
      
    testMerge: function(){ with(this) {
      assertEqual($H(Fixtures.many).inspect(), $H(Fixtures.many).merge().inspect());
      assertEqual($H(Fixtures.many).inspect(), $H(Fixtures.many).merge({}).inspect());
      assertEqual("#<Hash:{'a': 'A', 'b': 'B', 'c': 'C', 'd': 'D#', 'aaa': 'AAA'}>", $H(Fixtures.many).merge({aaa: 'AAA'}).inspect());
      assertEqual("#<Hash:{'a': 'A#', 'b': 'B', 'c': 'C', 'd': 'D#'}>", $H(Fixtures.many).merge(Fixtures.one).inspect());
    }},
    
    testToQueryString: function(){ with(this) {
      assertEqual('',                        $H({}).toQueryString())
      assertEqual('a=A%23',                  $H(Fixtures.one).toQueryString())
      assertEqual('a=A&b=B&c=C&d=D%23',      $H(Fixtures.many).toQueryString())
      assertEqual("a=b&c=",                  $H(Fixtures.value_undefined).toQueryString())
      assertEqual("a=b&c=",                  $H(Fixtures.value_null).toQueryString())
      assertEqual("a=b&c=0",                 $H(Fixtures.value_zero).toQueryString())
    }},
    
    testInspect: function(){ with(this) {
      assertEqual('#<Hash:{}>',              $H({}).inspect());
      assertEqual("#<Hash:{'a': 'A#'}>",     $H(Fixtures.one).inspect());
      assertEqual("#<Hash:{'a': 'A', 'b': 'B', 'c': 'C', 'd': 'D#'}>", $H(Fixtures.many).inspect());
    }}
  }, 'testlog');
// ]]>
</script>
</body>
</html>
